<script setup lang="ts">
import { weichatMessgaeConfig } from "./utils/hook";
import { PureTableBar } from "@/components/RePureTableBar";
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import Delete from "@iconify-icons/ep/delete";
import EditPen from "@iconify-icons/ep/edit-pen";
import AddFill from "@iconify-icons/ri/add-circle-line";
import getURL from "@/utils/http/address";
const {
  //getConfigList,
  columns,
  dataList,
  onSearch,
  loading,
  pagination,
  openDialog,
  handleDelete,
  handleSizeChange,
  handleCurrentChange
} = weichatMessgaeConfig();
</script>
<template>
  <div class="main">
    <PureTableBar title="AI配置" :columns="columns" @refresh="onSearch">
      <template #buttons>
        <el-button
          type="primary"
          :icon="useRenderIcon(AddFill)"
          @click="openDialog()"
        >
          新增AI配置
        </el-button>
      </template>
      <template v-slot="{ size }">
        <pure-table
          :pagination="pagination"
          :paginationSmall="size === 'small' ? true : false"
          @page-size-change="handleSizeChange"
          @page-current-change="handleCurrentChange"
          align-whole="center"
          showOverflowTooltip
          table-layout="auto"
          :loading="loading"
          :size="size"
          adaptive
          :data="dataList"
          :columns="columns"
          :default-sort="{ prop: 'id', order: 'descending' }"
          :header-cell-style="{
            background: 'var(--el-fill-color-light)',
            color: 'var(--el-text-color-primary)'
          }"
        >
          <template #image="{ row }">
            <img :src="getURL + row.aiHead" style="width: 40px; margin: auto" />
          </template>
          <template #operation="{ row }">
            <el-button
              class="reset-margin"
              link
              type="primary"
              :size="size"
              :icon="useRenderIcon(EditPen)"
              @click="openDialog('编辑', row)"
            >
              修改
            </el-button>

            <el-popconfirm
              :title="`是否删除配置：${row.tempName}`"
              @confirm="handleDelete(row)"
            >
              <template #reference>
                <el-button
                  class="reset-margin"
                  link
                  type="primary"
                  :size="size"
                  :icon="useRenderIcon(Delete)"
                >
                  删除
                </el-button>
              </template>
            </el-popconfirm>
          </template>
        </pure-table>
      </template>
    </PureTableBar>
  </div>
</template>
